package org.jash.ting13.entity

import android.content.Intent
import android.view.View
import org.jash.converters.Xpath
import org.jash.ting13.book.BookActivity

/**
 * Created by Jash
 */
data class SearchEntity (
    @Xpath(".//*[@class='list-book-dt']/a/text()")
    val title:String,
    @Xpath(".//*[@class='list-book-dt']/a/@href")
    val url:String,
    @Xpath(".//*[@class='list-imgbox']//img/@data-original")
    val img:String,
    @Xpath(".//*[@class='list-book-des']/text()")
    val des:String,
    @Xpath(".//*[@class='book-author']//a/text()")
    val author:List<String>,
    @Xpath(".//*[@class='book-boyin']//a/text()")
    val boyin:List<String>,
) {
    val authors
        get() = author.joinToString()
    val boyins
        get() = boyin.joinToString()

    fun showDetail(v: View) {
        v.context.startActivity(Intent(v.context, BookActivity::class.java).putExtra("url", url))
    }
}